package api

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"shop-api/pkg/log"
)

func Resp(c *gin.Context, data interface{}, err error) {
	if err == nil {
		c.JSON(http.StatusOK, gin.H{"code": 0, "data": data, "msg": "success"})
		return
	}
	log.LogError(err)
	c.JSON(http.StatusOK, gin.H{"code": -1, "data": data, "msg": err.Error()})
	return
}
